/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Database;

/**
 *
 * @author Windlord
 */
public class Ve {
    private int type;
    private ParseColumn Column; 
    private String Value;
    public Ve()
    {
        
    }

    /**
     * @return the type
     */
    public int getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(int type) {
        this.type = type;
    }

    /**
     * @return the Column
     */
    public ParseColumn getColumn() {
        return Column;
    }

    /**
     * @param Column the Column to set
     */
    public void setColumn(ParseColumn Column) {
        this.Column = Column;
    }

    /**
     * @return the Value
     */
    public String getValue() {
        return Value;
    }

    /**
     * @param Value the Value to set
     */
    public void setValue(String Value) {
        if (Value.equals("null") )
            this.Value=null;
        else
            this.Value = Value.replaceAll("\'", "");
    }
    
    public boolean CompareStr(Object CompareValue,String Operator)
    {
        if(CompareValue==null||Value==null)
        {
            if((Value==CompareValue&&Operator.equals("="))||(Value!=CompareValue&&Operator.equals("!=")))
                return true;
            else
                return false;
        }
        else
        {
            if(Operator.equals("="))
            {
                if(CompareValue.toString().trim().toLowerCase().equals(Value.toString().trim().toLowerCase()))    
                    return true;
                else
                    return false;
            }
            if(Operator.equals("!="))
            {
                if(!CompareValue.toString().trim().toLowerCase().equals(Value.toString().trim().toLowerCase()))    
                    return true;
                else
                    return false;
            }
            return false;
        }
    }
    
    public boolean CompareInt(Object CompareValue,String Operator)
    {
        if(CompareValue==null||Value==null)
        {
            if((Value==CompareValue&&Operator.equals("="))||(Value!=CompareValue&&Operator.equals("!=")))
                return true;
            else
                return false;
        }
        else
        {
            if(Operator.equals("="))
            {
                if(CompareValue.toString().toLowerCase().equals(Value.toString().toLowerCase()))    
                    return true;
                else
                    return false;
            }
            if(Operator.equals("!="))
            {
                if(!CompareValue.toString().toLowerCase().equals(Value.toString().toLowerCase()))    
                    return true;
                else
                    return false;
            }
            try
            {
                Integer.parseInt(CompareValue.toString());
                Integer.parseInt(Value);
                if(Operator.equals(">"))
                {
                    if(Integer.parseInt(CompareValue.toString())>Integer.parseInt(Value))
                        return true;
                    else
                        return false;
                }
                if(Operator.equals("<"))
                {
                    if(Integer.parseInt(CompareValue.toString())<Integer.parseInt(Value))
                        return true;
                    else
                        return false;
                }
                if(Operator.equals(">="))
                {
                    if(Integer.parseInt(CompareValue.toString())>=Integer.parseInt(Value))
                        return true;
                    else
                        return false;
                }
                if(Operator.equals("<="))
                {
                    if(Integer.parseInt(CompareValue.toString())<=Integer.parseInt(Value))
                        return true;
                    else
                        return false;
                }
                return false;
            }catch(NumberFormatException nx){
                    return false;
            }
        }
    }
}
